package com.ruoyi.jiajia.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.JiajiaCharityActivities;
import com.ruoyi.system.service.IJiajiaCharityActivitiesService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公益活动信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-06
 */
@Controller
@RequestMapping("/jiajia/jiajiaCharityActivities")
public class JiajiaCharityActivitiesController extends BaseController
{
    private String prefix = "jiajia/jiajiaCharityActivities";

    @Autowired
    private IJiajiaCharityActivitiesService jiajiaCharityActivitiesService;

    @RequiresPermissions("jiajia:jiajiaCharityActivities:view")
    @GetMapping()
    public String jiajiaCharityActivities()
    {
        return prefix + "/jiajiaCharityActivities";
    }

    /**
     * 查询公益活动信息列表
     */
    @RequiresPermissions("jiajia:jiajiaCharityActivities:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaCharityActivities jiajiaCharityActivities)
    {
        startPage();
        List<JiajiaCharityActivities> list = jiajiaCharityActivitiesService.selectJiajiaCharityActivitiesList(jiajiaCharityActivities);
        return getDataTable(list);
    }

    /**
     * 导出公益活动信息列表
     */
    @RequiresPermissions("jiajia:jiajiaCharityActivities:export")
    @Log(title = "公益活动信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaCharityActivities jiajiaCharityActivities)
    {
        List<JiajiaCharityActivities> list = jiajiaCharityActivitiesService.selectJiajiaCharityActivitiesList(jiajiaCharityActivities);
        ExcelUtil<JiajiaCharityActivities> util = new ExcelUtil<JiajiaCharityActivities>(JiajiaCharityActivities.class);
        return util.exportExcel(list, "公益活动信息数据");
    }

    /**
     * 新增公益活动信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存公益活动信息
     */
    @RequiresPermissions("jiajia:jiajiaCharityActivities:add")
    @Log(title = "公益活动信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaCharityActivities jiajiaCharityActivities)
    {
        return toAjax(jiajiaCharityActivitiesService.insertJiajiaCharityActivities(jiajiaCharityActivities));
    }

    /**
     * 修改公益活动信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaCharityActivities jiajiaCharityActivities = jiajiaCharityActivitiesService.selectJiajiaCharityActivitiesById(id);
        mmap.put("jiajiaCharityActivities", jiajiaCharityActivities);
        return prefix + "/edit";
    }

    /**
     * 修改保存公益活动信息
     */
    @RequiresPermissions("jiajia:jiajiaCharityActivities:edit")
    @Log(title = "公益活动信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaCharityActivities jiajiaCharityActivities)
    {
        return toAjax(jiajiaCharityActivitiesService.updateJiajiaCharityActivities(jiajiaCharityActivities));
    }

    /**
     * 删除公益活动信息
     */
    @RequiresPermissions("jiajia:jiajiaCharityActivities:remove")
    @Log(title = "公益活动信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaCharityActivitiesService.deleteJiajiaCharityActivitiesByIds(ids));
    }
}
